from django.conf.urls import url
from rest_framework.routers import DefaultRouter

from . import views

urlpatterns = [
    # url(r'^books/$',views.BooksAPIVIew.as_view()),
    # url(r'^book/(?P<pk>\d+)/$',views.BookAPIView.as_view())
    # 基类APIView   设置响应全部的数据表的路由信息
    # url(r'^books/$',views.BookListView.as_view()),
    #设置获取单一数据的url路径
    # url(r'^books/(?P<pk>\d+)/$',views.BookDetailView.as_view()
    #扩展类
    #BookListView
    # url(r'^books/$',views.BookListView.as_view())
    #RetrieveModelMixin
    # url(r'^books/(?P<pk>\d+)/$',views.BookDetailview.as_view())
    #设置视图集ViewSet
    # url(r'^books/$',views.BookInfoViewSet.as_view({'get':'list'})),
    # url(r'^books/(?P<pk>\d+)/$',views.BookInfoViewSet.as_view({'get':'retrieve'}))
    # 设置视图集子类
    url(r'^books/$', views.BookInfoViewSet.as_view({'get': 'list'})),
    url(r'^books/(?P<pk>\d+)/$', views.BookInfoViewSet.as_view({'get': 'retrieve'})),
    url(r'^books/latest/$',views.BookInfoViewSet.as_view({'get':'latest'})),
    url(r'^books/(?P<pk>\d+)/read/$',views.BookInfoViewSet.as_view({'put':'read'})),

]
# router = DefaultRouter()
# router.register(r'books',views.BookInfoViewSet) #向路由注册视图
# urlpatterns += router.urls #将路由器中的所有路由信息追加到django的路由列表中

